
load('summary_data/figA11.rda')

rbindlist(list(oc, ob, rt16, rt20)) %>% 
  mutate(class = factor(class, levels = unique(class))) %>%
  mutate(lty = if_else(str_starts(class, 'R'), 'solid', 'dashed'),
         a = if_else(str_starts(class, 'R'), 1, 1)) %>% 
  ggplot(aes(x = nat_quant, y = V1, fill = class, group = class, color = class, linetype = lty, alpha = a)) +
  geom_point(aes(alpha=a)) +
  geom_line() +
  theme_light() +
  scale_x_discrete(labels = x_l) +
  scale_linetype_identity() +
  scale_alpha_identity() +
  scale_color_manual(values = c("deepskyblue", "darkslateblue", "brown1", "darkred")) +
  scale_y_continuous(labels=scales::label_percent(), limits = c(0,.75))+
  labs(x = 'National Wealth Bin', y = '% Donor Retention', fill = element_blank()) +
  guides(
    alpha = 'none',
    fill = 'none',
    color = guide_legend(
      nrow = 2,
      byrow = TRUE,
      title = element_blank()
    )
  ) +
  theme(
    legend.position = c(0.4, 0.8),
    axis.text.x = element_text(
      angle = 25,
      vjust = .85,
      hjust = 0.5,
      size = 7
    ),
    legend.text = element_text(size = 7),
    strip.background = element_rect(fill = 'white'),
    strip.text.x = element_text(
      face = 'bold',
      size = 10,
      color = 'black'
    ),
    legend.spacing.y = unit(0, 'cm'),
    text = element_text(face = 'bold')
  )

ggsave('figures/figA11.pdf', width = 6, height = 4, units = 'in')
